package com.csjy.migration.hnnd.workflow;

import com.csjy.migration.hnnd.BusinessTool;
import com.csjy.migration.hnnd.DbUtil;
import com.csjy.migration.hnnd.ProgramArgument;
import com.csjy.migration.hnnd.annotation.Task;
import com.csjy.migration.hnnd.business.NdBpmFeeCollectionRecord;
import com.csjy.migration.hnnd.business.NdBpmRecoveryProceeds;
import com.csjy.migration.hnnd.business.SourceBusinessData;

import javax.script.ScriptException;
import java.util.Map;

/*
代偿项目终结(item-ask-inst-relieve-hny)
phs
*/

public class ItemAskInstRelieveHny extends WorkflowMigration{
    private NdBpmFeeCollectionRecord ndBpmFeeCollectionRecord = null;
    private NdBpmRecoveryProceeds ndBpmRecoveryProceeds = null;

    public ItemAskInstRelieveHny(DbUtil sourceDbUtil, DbUtil targetDbUtil, SourceBusinessData sourceData, ProgramArgument programArgument, String projectId, String procInstId, Map procInstRow) throws Exception {
        super(sourceDbUtil, targetDbUtil, sourceData, programArgument, projectId, procInstId, procInstRow);
        this.customInitData();
    }

    @Override
    public void customInitData() throws Exception {
        this.ndBpmFeeCollectionRecord = new NdBpmFeeCollectionRecord(sourceDbUtil,targetDbUtil,sourceData,programArgument,projectId,procInstId);
        this.ndBpmRecoveryProceeds = new NdBpmRecoveryProceeds(sourceDbUtil,targetDbUtil,sourceData,programArgument,projectId,procInstId);
        this.curBizType = "dcxmzj";
    }

    @Override
    public void customInsertOrUpdateData() throws Exception {
        this.ndBpmFeeCollectionRecord.start();
        this.ndBpmRecoveryProceeds.start();
    }

    @Task("代偿项目终结@追偿主责任人提交资料")
    public void zczrrrtjzl() throws Exception, ScriptException {

        this.curModelMap.put("all",new String[]{"task1535698473776zcsddydce","追偿所得低于代偿额"});
/*        this.curModelMap.put("接收人员",new String[]{"task1535698484609zcsdbdydce","追偿所得不低于代偿额"});*/
        this.curCustomData.put("compensatoryAmount",this.getJbpmVarInstValueByName("dcje"));
        this.curCustomData.put("totalRecoveryIncome",this.getJbpmVarInstValueByName("zcsdze"));
        this.curCustomData.put("recoverTheCost",this.getJbpmVarInstValueByName("zcfy"));
        this.curAffixType = "tjfj";
        this.setCommonData(true,null);
        this.ndBpmFeeCollectionRecord.getTaskParamMap().put(this.curJbpmTaskInstanceId, this.initTaskParamMap());
        this.ndBpmRecoveryProceeds.getTaskParamMap().put(this.curJbpmTaskInstanceId,this.initTaskParamMap());
    }
    @Task("代偿项目终结@法务部门经理审批")
    public void fwbmjlsh() throws Exception {
        this.curModelMap.put("同意",new String[]{"task1535698475248ty","同意"});
        this.curModelMap.put("不同意",new String[]{"endbty","不同意"});
        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@评审部秘书确定评审委员")
    public void spbmsqrpswy() throws Exception {
        this.curModelMap.put("all",new String[]{"task1535698477313xyb","下一步"});

        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@评审委员投票表决")
    public void pswytpbj() throws Exception {
        // 新 投票结果(1:通过 2:不通过 3：续议 4：补材料 5：申请上会 其中 3：续以在老流程中是没有的
        // 老 voteResult "0=同意,1=不同意";
        this.curModelMap.put("all",new String[]{"task1535698477313xyb","下一步"});
        String voteResult = this.getJbpmVarInstValueByName("voteResult");
        if(voteResult == null){
            this.curCustomData.put("voting_results", "");
        } else {
            Integer voteResultInt = Integer.parseInt(voteResult)+1;
            this.curCustomData.put("voting_results",voteResultInt);
        }
        this.curCustomData.put("rating_description",this.getJbpmVarInstValueByName("remark"));
        this.curAffixType = "fjcl";
        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@评审秘书提交董事会决议")
    public void psmstjdshjy() throws Exception {
        this.curModelMap.put("同意",new String[]{"task1535698483186tg","同意"});
        this.curModelMap.put("未通过",new String[]{"task1535698483186tg","未通过"});
        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@董事长审批")
    public void dszsp() throws Exception {
        this.curModelMap.put("同意",new String[]{"task1535698484609ty","同意"});
        this.curModelMap.put("不同意",new String[]{"endbty","不同意"});

        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@财务部核算处理确认")
    public void cwbhsclqr() throws Exception {
        this.curModelMap.put("通过",new String[]{"task1535698485993tg","通过"});
        this.setCommonData(true,null);
    }
    @Task("代偿项目终结@档案管理室处理档案")
    public void daglsclda() throws Exception {
        this.curModelMap.put("all",new String[]{"endjs","结束"});
        this.setCommonData(true,null);
    }

}
